package com.wizo.csb.generator;

import java.util.Random;

public class ContainerNameGenerator extends Generator{
	String[] _containers;
	int _containersCount;
	Random _random;
	int _index;
	String _lastString;
	
	public ContainerNameGenerator(int containersCount){
		_containersCount = containersCount;
		_containers = new String[_containersCount];
		_random = new Random();
		_index = 0;
		_lastString = null;
	}
	
	public void addValue(String container){
		_containers[_index++] = container;
		if(_index==_containersCount){
			_index = 0;
			return;
		}
	}
	
	@Override
	public String nextString() {
		_index = _random.nextInt(_containersCount);
		_lastString = _containers[_index];
		return _lastString;
	}

	@Override
	public String lastString() {
		return _lastString;
	}
	
	public String containerAt(int index){
		return _containers[index];
	}
}
